<%@ page import="cwb1.DivisionRegistry" %>
<%@ page import="cwb1.DivisionFactory" %>
<%@ page import="cwb1.Division" %>
<%@ page import="cwb1.Course" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="cwb1.UserRegistry" %>
<%@ page import="cwb1.DefaultData" %>

<%  String tempId = null; %>


<head>
	<title> Register - Aurora </title>
	<link rel=StyleSheet href="stylesheets/registerStyle.css" type="text/css" media=all>
	
	<script>
	
	function checkInput() 
	{
		var username = document.getElementById("username").value;
		var password = document.getElementById("password").value;
		var password2 = document.getElementById("password2").value;
		var succeeded = false;
		
		if(password == password2 && username != "" && password != "") {
			succeeded = true;
		}
		
		return succeeded
		
	}
	
	
	</script>
</head>

<body>

	<div class="container">
	<div class="form">
	<a href="login.jsp"><img src="stylesheets/images/logo.png" alt="Aurora" width="288" height="120" /></a>
					<form action="/reg" method="post" onsubmit="return checkInput()">
					<table>
					<tr>
					<td>Your username </td> <td> <input id="username" type="text" name="username" /> </td>
					</tr>
					<tr>
					<td>Choose a password </td> <td> <input type="password" name="password" id="password"/> </td>
					</tr>
					<tr>
					<td>Re-enter the password </td> <td> <input type="password" name="password2" id="password2" /> </td>
					</tr>
					<tr>
					<td>Your student number </td> <td> <input type="text" name="usernumber" /> </td>
					</tr>
       		    	</table>
       		    	<p>Select the courses you are submitted to.</p>
       		    	<ul>
       		    	<%
       		    	DefaultData.createDefaultData();
       		    	List<Division> divisions = DivisionRegistry.getInstance().getAllType(DivisionFactory.COURSE);
       		    		
       		    	for(Division element: divisions) {   
       		    		Course course = (Course) element;
       		    		String courseName = course.getCourseName(); %>
       		    		<li> <input type="checkbox" onclick="addCourse()" name="<%=course.getId()%>" value="<%=course.getId()%>" />
       		    		<%=courseName %></li>
       		    	
       		    	<%
       		    			
       		    	}   		    			
					  %>
					</ul>	
					<input type="submit" value="Register" class="button" />
       		    
					</form> 
	</div>
	</div>
</body>
</html>